$(function () {
  
    var citrusId= getQueryString("citrusId");
    console.log(citrusId);
    //根据id从数据库中获取修改前的值
    $.post(
        "/citrusmonitor/citrus.do?method=findCitrusById&citrusId="+citrusId,

        function (res) {
         var data = res.data;
         $("#citrus_id").val(data.citrusId),
	 /*    $("#technology_id").val(data.technologyId),*/
	     $("#citrus_name").val(data.citrusName),
         $("#description").val(data.description),
         $("#period").val(data.period),
	     $("#file_path").val(data.filePath)
        },
        "json"
    );
    //edit按钮绑定事件
    $("#edit").click(function () {

        $.post(
            "/citrusmonitor/citrus.do?method=modifyCitrus",
            {
                "citrusId": $("#citrus_id").val(),
//                "technologyId": $("#technology_id").val(),
                "citrusName": $("#citrus_name").val(),
                "description": $("#description").val(),
                "period": $("#period").val(),
//                "filePath": $("#file_path").val()
            },
           function(res){
                console.log(res);
                res = JSON.parse(res);
                if(res.status==1){
                    alert("信息提示修改成功");
                    window.location.href="show.html";
                }else{
                    alert("信息提示修改失败");
                }}
        )
    })
})

function getQueryString(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    console.log(reg );
    var r = window.parent.document.getElementById("rightframe").contentWindow.location.search.substr(1).match(reg);
    if(r!=null){
        return  unescape(r[2]);
    }
    return null;
}
